package com.hejjon.controller;

import com.hejjon.core.bean.ResponseResult;
import com.hejjon.core.controller.BaseController;
import com.hejjon.core.domain.entity.FeatureCategory;
import com.hejjon.core.domain.vo.FeatureCategoryVO;
import com.hejjon.service.IFeatureCategoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 特征分类控制层
 * @author: cs
 * @date: 2025-02-26 15:59:30
 * @since: 1.0
 */
@RestController
@RequestMapping("/feature/category")
public class FeatureCategoryController extends BaseController {

    @Resource
    private IFeatureCategoryService featureCategoryService;

    @PostMapping("/create")
    public ResponseResult save(@RequestBody FeatureCategory entity) {
        boolean sta = featureCategoryService.createCategory(entity);
        return toResult(sta, "特征分类创建成功");
    }


    @GetMapping("/getTreeData")
    public ResponseResult getTreeData(@RequestParam("kind") String kind) {
        List<FeatureCategoryVO> treeData = featureCategoryService.findTreeData(kind);
        return success(treeData);
    }


    @GetMapping("/removeById")
    public ResponseResult removeById(@RequestParam("id") String id, @RequestParam("kind") String kind) {
        boolean b = featureCategoryService.removeById(id, kind);
        return toResult(b, "特征分类删除成功");
    }


    @PostMapping("/update")
    public ResponseResult update(@RequestBody FeatureCategory category) {
        boolean b = featureCategoryService.updateCategory(category);
        return toResult(b, "特征分类更新成功");
    }




}
